With PERMISSIVE turned on, diagnose missing Enums and Bools, and improve the
authorEwan Mellor <ewan@xensource.com>
Mon, 4 Dec 2006 10:20:56 +0000 (10:20 +0000)
committerEwan Mellor <ewan@xensource.com>
Mon, 4 Dec 2006 10:20:56 +0000 (10:20 +0000)
diagnosis of missing structure values.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/libxen/src/xen_common.c

index 50b8e377e055a88969cf72720c584bf2e3440739..ea0909d1a4f9650017538b6d4a30a9e17e5995d5 100644 (file)
@@ -518,8 +518,14 @@ static void parse_into(xen_session *s, xmlNode *value_node,
         xmlChar *string = string_from_value(value_node, "string");
         if (string == NULL)
         {
+#if PERMISSIVE
+            fprintf(stderr,
+                    "Expected an Enum from the server, but didn't get one\n");
+            ((int *)value)[slot] = 0;
+#else
             server_error(
                 s, "Expected an Enum from the server, but didn't get one");
+#endif
         }
         else
         {
@@ -567,8 +573,14 @@ static void parse_into(xen_session *s, xmlNode *value_node,
         xmlChar *string = string_from_value(value_node, "boolean");
         if (string == NULL)
         {
+#if PERMISSIVE
+            fprintf(stderr,
+                    "Expected a Bool from the server, but didn't get one\n");
+            ((bool *)value)[slot] = false;
+#else
             server_error(
                 s, "Expected a Bool from the server, but didn't get one");
+#endif
         }
         else
         {
@@ -764,7 +776,6 @@ static void parse_into(xen_session *s, xmlNode *value_node,
                 cur = cur->next;
             }
 
-#if !PERMISSIVE
             /* Check that we've filled all fields. */
             for (size_t i = 0; i < member_count; i++)
             {
@@ -781,15 +792,20 @@ static void parse_into(xen_session *s, xmlNode *value_node,
 
                 if (j == seen_count)
                 {
+#if PERMISSIVE
+                    fprintf(stderr,
+                            "Struct did not contain expected field %s.\n",
+                            mem->key);
+#else
                     server_error_2(s,
                                    "Struct did not contain expected field",
                                    mem->key);
                     free(result);
                     free(checklist);
                     return;
+#endif
                 }
             }
-#endif
 
             free(checklist);
             ((void **)value)[slot] = result;